package edu.towson.greenteam.tab;

import junit.framework.Assert;

import org.junit.Test;

import edu.towson.greenteam.offer.Offers;
import edu.towson.greenteam.offer.Offer;
import edu.towson.greenteam.order.Order;
import edu.towson.greenteam.table.Table;

public class tabTest {

	@Test
	public void testTab() {
		Tab tabInstance = new Tab(123);
		Assert.assertEquals(123, tabInstance.getId());
		Assert.assertEquals(false, tabInstance.isPaid());
		tabInstance.setPaymentstatus(true);
		Assert.assertEquals(true, tabInstance.isPaid());
	}
	
	@Test
	public void testTabOfferItr()
	{
		Offers testOffers = new Offers();
		testOffers.add(new Offer(1, "first offer", "description", 10, 25));
		testOffers.add(new Offer(2, "second offer", "description", 15, 50));
		testOffers.add(new Offer(3, "third offer", "description", 20, 100));

		//create discount
		Tab withDiscount = new Tab(2);
		withDiscount.addMenuItem(new Order(0, "expensive salad", 100, new Table()));
		withDiscount.applyBestDiscount(testOffers);
		float testFloat = 20;
		Assert.assertEquals(testFloat, withDiscount.getDiscount());
	}
	
	@Test
	public void testTabPayStatusItr()
	{
		Tabs tabs = new Tabs();
		//create notPaid
		Tab notPaidTab = new Tab(1);
		//create paid
		Tab paidTab = new Tab(2);
		paidTab.setPaymentstatus(true);
		//add tabs
		tabs.add(notPaidTab);
		tabs.add(paidTab);
		//create iterator
		TabNotPaidItr tabOfferItr = new TabNotPaidItr(tabs);
		//ensure you only get "not paid"
		while (tabOfferItr.hasNext())
		{
			Tab tab = tabOfferItr.next();
			Assert.assertEquals(1, tab.getId());
			tabOfferItr.next();
		}
	}
}
